---
category: Object
contributors:
    - robinpokorny
created: '2020-05-18'
title: Create an object from the pairs of key and value
updated: '2020-05-20'
---

**JavaScript version**

```js toObj.js
const toObj = (arr) => Object.fromEntries(arr);

// Or
const toObj = (arr) => arr.reduce((a, c) => ((a[c[0]] = c[1]), a), {});
```

**Examples**

```js examples.js
toObj([
    ['a', 1],
    ['b', 2],
    ['c', 3],
]); // { a: 1, b: 2, c: 3 }
```
